#include "precompiled.h"
#include "buffsdialog.h"
using namespace std;
using namespace weo::engine::item;
using namespace weo::ui;
BuffsDialog::BuffsDialog(QWidget* parent /*= 0*/, Qt::WFlags flags /*= 0*/) : QDialog(parent, flags)
{
    setupUi(this);
}
void BuffsDialog::setBuffs(const std::map<std::string, weo::engine::character::Buff>& buffs, bool bok)
{
    BuffsListWidget->clear();
    std::map<std::string, weo::engine::character::Buff>::const_iterator it;
    for(it = buffs.begin(); it != buffs.end();it++)
    {
        BuffsListWidget->addItem(tr(it->first.c_str()));
    }
    BuffsListWidget->addItem(tr("Blessing of Kings"));
    for(it = buffs.begin(); it != buffs.end();it++)
    {
        QList<QListWidgetItem *>items = BuffsListWidget->findItems(tr(it->first.c_str()),Qt::MatchFixedString);
        if(items.empty()) continue;
        QListWidgetItem *item = items[0];
        item->setSelected(it->second.Active());
    }
    QList<QListWidgetItem *>items = BuffsListWidget->findItems(tr("Blessing of Kings"),Qt::MatchFixedString);
    if(items.empty()) return;
    QListWidgetItem *item = items[0];
    item->setSelected(bok);
    BuffsListWidget->sortItems();
}
void BuffsDialog::getBuffs(std::map<std::string, weo::engine::character::Buff>* buffs)
{
    std::map<std::string, weo::engine::character::Buff>::iterator it;
    for(it = buffs->begin(); it != buffs->end();it++)
    {
        QList<QListWidgetItem *>items = BuffsListWidget->findItems(tr(it->first.c_str()),Qt::MatchFixedString);
        if(items.empty()) continue;
        QListWidgetItem *item = items[0];
        it->second.Active(item->isSelected());
    }
}